<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
    <% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
        + request.getServerPort() + path + "/" ; %>

        <!DOCTYPE html>
        <html>

        <head>
            <base href="<%=basePath%>">

            <title>排货计划</title>

            <meta http-equiv="pragma" content="no-cache">
            <meta http-equiv="cache-control" content="no-cache">
            <meta http-equiv="expires" content="0">
            <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
            <meta http-equiv="description" content="This is my page">
            <!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
            <style>

            </style>
        </head>

        <body>
            <%@ include file="/WEB-INF/jsp/common/header.jsp" %>
                <%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

                    <script type="text/javascript">
                        $(function () {
                            $('.divplanReceiveCode').hide();
                            $('.divplanPreCode').hide();
                            $('#startTime').datebox('setValue', getNowFormatDate());
                            $('#endTime').datebox('setValue', getNowFormatDate());
                            bindgrid();
                            $('#startPlanTime').datebox('setValue', getBeforeCurrentDate90Days());
                            $('#endPlanTime').datebox('setValue', getNowFormatDate());
                            bindContractGrid();
                            suppliesDatagird();
                            setMMsDataGrid();
                            // 绑定文件上传的点击事件
                            $("#uploadbtn").bind("click", function (e) {
                                $("#uploadpicker").click();
                            });
                        });
                    </script>
                    <script>
                        // 库存地点
                        function initStock(newValue) {
                            $('#stoCode').combobox({
                                method: 'get',
                                url: 'sysDict/queryItemByTypeName?dicName=' + newValue + '-库存地点',
                                valueField: "dicValue",
                                textField: "dicName",
                                editable: false,
                                required: true
                            });
                            $('#planReceiveCode').combobox({
                                method: 'get',
                                url: 'sysDict/queryItemByTypeName?dicName=' + newValue + '-库存地点',
                                valueField: "dicValue",
                                textField: "dicName",
                                editable: false
                            });
                        }

                        // 预装编号
                        function initYZ() {
                            $('#planPreCode').combogrid({
                                method: 'post',
                                url: 'tm/plan/selectList?status=1&orderCode=5',
                                idField: "planCode",
                                panelWidth: 500,
                                textField: "planCode",
                                editable: false,
                                multiple: true,
                                columns: [[
                                    { field: 'ck', checkbox: true },
                                    { field: 'planCode', title: '计划编码', width: 100 },
                                    { field: 'planName', title: '计划名称', width: 300 }
                                ]],
                                fitColumns: true
                            });
                        }
                    </script>
                    <script type="text/javascript">
                        var selectedFileList = [];//已选文件列表
                        var succsessCount = 0;//上传成功文件个数
                        var errorCount = 0;//上传失败文件个数
                        /************文件处理部分*************/


                        /**
                         *文件框改变事件
                         */
                        function changeFile() {
                            var files = $("#uploadpicker").prop("files");
                            $
                                .each(
                                    files,
                                    function (index, item) {
                                        let choiseFile = $("#checkfileList>li");
                                        if (choiseFile.length > 0) {//文件去重
                                            let count = 0;
                                            $.each(choiseFile, function (index1, item1) {
                                                if (item.name == item1.innerText) {
                                                    count++;
                                                }
                                            });
                                            if (count == 0) {
                                                if (checkFileLength(item.size)) {
                                                    if (item.name.includes('&') || item.name.includes('\\') || item.name.includes(' ')) {
                                                        alert('文件名不能包含&、\\、空格等特殊字符！');
                                                        return;
                                                    }
                                                    $("#checkfileList")
                                                        .append(
                                                            "<li class=\"fileinfo\">"
                                                            + item.name
                                                            + "<a style=\"display: none; color: red; margin-left: 10px;\" href=\"javascript:void(0)\" onclick=\"RemoveFile(this,'"
                                                            + item.name
                                                            + "')\">删除</a>"
                                                            + "</li>");
                                                    selectedFileList.push(item);
                                                    AddMoushover();
                                                }
                                            }
                                        } else {
                                            if (checkFileLength(item.size)) {
                                                if (item.name.includes('&') || item.name.includes('\\') || item.name.includes(' ')) {
                                                    alert('文件名不能包含&、\\、空格等特殊字符！');
                                                    return;
                                                }
                                                $("#checkfileList")
                                                    .append(
                                                        "<li class=\"fileinfo\">"
                                                        + item.name
                                                        + "<a style=\"display: none; color: red; margin-left: 10px;\" href=\"javascript:void(0)\" onclick=\"RemoveFile(this,'"
                                                        + item.name
                                                        + "')\">删除</a>"
                                                        + "</li>");
                                                selectedFileList.push(item);
                                                AddMoushover();
                                            }
                                        }
                                    });
                        }

                        /**
                         *    判断文件是否超过限制大小
                         * @param fileLen
                         * @returns {boolean}
                         */
                        function checkFileLength(fileLen) {
                            if (fileLen > 102400000) {
                                $.messager.alert("提示", "上传文件大小不能超过100M", "error");
                                return false;
                            }
                            return true;
                        }

                        /**
                         * //添加鼠标经过事件，鼠标划过时显示“删除”
                         * @constructor
                         */
                        function AddMoushover() {
                            $(".fileinfo").hover(function () {
                                $(this).find("a").last().css("display", "");
                            }, function () {
                                $(this).find("a").last().css("display", "none");
                            });
                        }

                        /**
                         *  移除已选择的文件
                         */

                        function RemoveFile(obj, fileId) {
                            $.messager.confirm("提示", "确认删除当前文件?", function (e) {
                                if (e) {
                                    let index = $("#checkfileList>li").index($(obj).parent());
                                    selectedFileList.splice(index, 1);
                                    $(obj).parent().remove();

                                    $.ajax({
                                        type: "post",
                                        async: false,
                                        url: 'file/deleteFile?fileId=' + fileId,
                                        success: function (data) {
                                            $.messager.alert('消息', data);
                                        },
                                        error: function (XMLHttpRequest, textStatus,
                                            errorThrown) {
                                            $.messager.alert('消息', errorThrown);
                                        }
                                    });

                                }
                            });
                        }

                        /**
                         * 取得该条数据所属的文件列表
                         * @param row
                         */
                        function getFileList(row) {
                            $.ajax({
                                type: "post",
                                async: false,
                                url: "file/getFileList",
                                data: {
                                    fileTable: "tm_plan",
                                    fileRow: row.planId
                                },
                                success: function (data) {
                                    const dataArray = eval(data);
                                    initFile(dataArray, row.status);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }

                        /**
                         * 初始化该条数据的文件列表
                         * @param dataArray
                         */
                        function initFile(dataArray, status) {
                            $("#checkfileList").empty();
                            // 			sselectedFileNameList = [];
                            selectedFileList = [];
                            dataArray
                                .forEach(function (e, i, a) {
                                    $("#checkfileList")
                                        .append(
                                            "<li class=\"fileinfo\">"
                                            + "<a style=\" color: blue; margin-left: 30px;\" href=\"javascript:void(0)\" onclick=\"downloadFile('" + e.FILE_NAME + "','"
                                            + e.FILE_ID
                                            + "')\">"
                                            + e.FILE_NAME
                                            + "</a>"
                                            + (status > 0 ? '' : "<a style=\"display: none; color: red; margin-left: 30px;\" href=\"javascript:void(0)\" onclick=\"RemoveFile(this,'"
                                                + e.FILE_ID + "')\">删除</a>")
                                            + "</li>");
                                    if (status > 0) {
                                    } else {
                                        AddMoushover();
                                    }
                                });
                        }


                        // 文件下载
                        function downloadFile(fileName, fileRow) {
                            let url = 'api/file/download?id=' + fileRow
                            let xhr = new XMLHttpRequest()
                            xhr.open('GET', url, true)
                            xhr.setRequestHeader('token', localStorage.getItem('tokenSupply'));
                            xhr.setRequestHeader('userType', localStorage.getItem('userType'));
                            xhr.responseType = 'blob'
                            xhr.onload = function (data) {
                                if (this.status == 200) {
                                    let blob = this.response
                                    let reader = new FileReader()
                                    reader.readAsDataURL(blob)
                                    reader.onload = function (e) {
                                        let a = document.createElement('a')
                                        a.download = fileName
                                        a.href = e.target.result
                                        $('body').append(a)
                                        a.click()
                                        $(a).remove()
                                    }
                                } else {

                                }
                            }
                            xhr.send()
                        }
                    </script>

                    <script>
                        function del(node) {
                            $.ajax({
                                type: "delete",
                                async: false,
                                url: 'tm/plan/delete?' + 'planId=' + node.planId,
                                //                dataType: "xml",				
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                    $('#addWindow').window('close');
                                    selectList();
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }

                        function back(node) {
                            $.ajax({
                                type: "get",
                                async: false,
                                url: 'tm/plan/back?planId=' + node.planId,
                                //                dataType: "xml",				
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                    selectList();
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }

                        function save(status) {
                            if (!$('#fm').form('validate')) {
                                $.messager.alert('消息', '请输入必填项！');
                                return;
                            }
                            if ($('#ordCode').combobox('getValue') == '3' && !$('#planReceiveCode').combobox('getValue')) {
                                $.messager.alert('消息', '调拨订单请选择收货仓库！');
                                return;
                            }
                            var row = $('#dg').datagrid('getSelected');
                            var model = {
                                planId: $('#planId').val(), createId: $('#createId').val(),
                                planCode: $('#planCode').textbox('getValue'), planName: $('#planName').textbox('getValue'),
                                ordCode: $('#ordCode').combobox('getValue'), ordName: $('#ordCode').combobox('getText'),
                                facCode: $('#facCode').combobox('getValue'), facName: $('#facCode').combobox('getText'),
                                conFactoryCode: $('#conFactoryCode').combobox('getValue'), conFactoryName: $('#conFactoryCode').combobox('getText'),
                                stoCode: $('#stoCode').combobox('getValue'), stoName: $('#stoCode').combobox('getText'),
                                planReceiveCode: $('#planReceiveCode').combobox('getValue'), planReceiveName: $('#planReceiveCode').combobox('getText'),
                                planPreCode: $('#planPreCode').combogrid('getValues').join(','), foreignName: $('#foreignName').textbox('getText'),
                                conCode: $('#conCode').textbox('getValue'), conName: $('#conName').textbox('getText'), draId: $('#draId').val(),
                                planStride: $('#planStride ').combobox('getValue'), sendDate: $('#sendDate').datebox('getValue'),
                                godNum: $('#godNum').textbox('getValue'), planReachDate: $('#planReachDate').datebox('getValue'),
                                cusCode: $('#cusCode').textbox('getValue'), cusName: $('#cusName').textbox('getValue'),
                                skuCode: $('#skuCode').textbox('getValue'),
                                skuDetail: $('#skuDetail').combobox('getValue'), skuNum: $('#skuNum').numberbox('getValue'),
                                proCode: $('#proCode').textbox('getValue'), proName: $('#proName').textbox('getValue'),
                                proNum: $('#proNum').numberbox('getValue'),
                                pakModeCode: $('#pakModeCode').combobox('getValue'), pakModeName: $('#pakModeCode').combobox('getText'),
                                pak1Code: $('#pak1Code').textbox('getValue'), pak1Name: $('#pak1Name').textbox('getValue'), pak1Num: $('#pak1Num').numberbox('getValue'),
                                pak2Code: $('#pak2Code').textbox('getValue'), pak2Name: $('#pak2Name ').textbox('getValue'),
                                pak2Num: $('#pak2Num').numberbox('getValue'),
                                planFetchNum: $('#planFetchNum ').textbox('getValue'),
                                planCheckNum: $('#planCheckNum').textbox('getValue'),
                                planOrdRemark: $('#planOrdRemark').textbox('getValue'),
                                planSendRemark: $('#planSendRemark').textbox('getValue'), planReceiveRemark: $('#planReceiveRemark').textbox('getValue'),
                                planReceiveTel: $('#planReceiveTel').textbox('getValue'), planArriveTime: $('#planArriveTime').datetimebox('getValue'),
                                planIsWeight: $('#draIsPlanAccounting').combobox('getValue'),
                                draTransportName: $('#draTransportName').combobox('getText'), draTransportId: $('#draTransportName').combobox('getValue'),
                                draCreatorName: $('#draCreator').textbox('getValue'), draCreatorId: $('#draCreatorId').val(),
                                deptName: $('#deptName').textbox('getValue'), createId: PUser.userid
                            };
                            if (!$('#conCode').textbox('getValue')) {
                                model.draCreatorId = '';
                            }
                            model.status = '0';
                            $.ajax({
                                type: "post",
                                async: false,
                                dataType: "json",
                                url: 'tm/plan/save',
                                data: JSON.stringify(model),
                                contentType: "application/json",
                                success: function (data) {
                                    if (data.code != 60200) {
                                        $.messager.alert('消息', data.msg);
                                    } else {
                                        $('#planId').val(data.data.planId);
                                        $('#planCode').textbox('setValue', data.data.planCode);
                                        saveAttch(data.data, data.data.planId, status)
                                    }
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            })

                        }

                        function commit(obj) {
                            $.ajax({
                                type: "post",
                                async: false,
                                dataType: "json",
                                url: 'tm/plan/commit',
                                data: JSON.stringify(obj),
                                contentType: "application/json",
                                success: function (data) {
                                    if (data.code != 60200) {
                                        $.messager.alert('消息', data.msg);
                                        selectList();
                                    } else {
                                        $.messager.alert('消息', data.msg);
                                        selectList();
                                        $('#addWindow').window('close');
                                    }
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            })
                        }

                        /**
                         * 保存附件
                         */
                        function saveAttch(row, rowId, action) {
                            let saveNum = 0
                            if (selectedFileList.length > 0) {
                                $.each(selectedFileList, function (index, item) {
                                    showFilediv();
                                    var dataform = new FormData();
                                    dataform.append("file", item);
                                    var xmlhttp = null;
                                    if (window.XMLHttpRequest) {// code for all new browsers
                                        xmlhttp = new XMLHttpRequest();
                                    } else if (window.ActiveXObject) {// code for IE5 and IE6
                                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                                    }
                                    if (xmlhttp != null) {
                                        xmlhttp.open("POST", "api/file/springUpload?fileRow=" + rowId
                                            + "&fileTable=tm_plan&fileName="
                                            + item.name, true);
                                        xmlhttp.setRequestHeader('token', localStorage.getItem('token'));
                                        xmlhttp.setRequestHeader('userType', localStorage.getItem('userType'));
                                        xmlhttp.send(dataform);
                                        xmlhttp.onreadystatechange = callbackMethods;
                                    } else {
                                        alert("你的浏览器版本不兼容，请使用更高版本的浏览器");
                                    }

                                    function callbackMethods() {
                                        if (xmlhttp.readyState == 4) {
                                            if (xmlhttp.status == 200) {
                                                saveNum += 1
                                                if (saveNum == selectedFileList.length) {
                                                    hideFilediv();
                                                    if ('1' == action) {
                                                        commit(row)
                                                    } else {
                                                        $.messager.alert('消息', '保存成功！');
                                                        selectList();
                                                        $('#addWindow').window('close');
                                                    }
                                                }
                                            }
                                        } else {
                                            if (xmlhttp.status == 500) {
                                            }
                                        }
                                    }
                                });
                            } else {
                                if ('1' == action) {
                                    commit(row)
                                } else {
                                    $.messager.alert('消息', '保存成功！');
                                    selectList();
                                    $('#addWindow').window('close');
                                }
                            }
                        }

                        function editrow(row) {
                            initYZ();
                            //编辑用户
                            // var row = $('#dg').datagrid('getSelected');
                            if (row) {
                                $('#addWindow').window('open');
                                $('#frmCheck').form('load', row);
                                $('#facCode').combobox('setValue', row.facCode);//提前赋值
                                $('#fm').form('load', row);
                                $('#facCode').combobox('setValue', row.facCode);//提前赋值
                                $('#conFactoryCode').combobox('setValue', row.conFactoryCode);
                                $('#stoCode').combobox('setValue', row.stoCode);
                                $('#planReceiveCode').combobox('setValue', row.planReceiveCode);
                                $('#pakModeCode').combobox('setValue', row.pakModeCode);
                                $('#planArriveTime').datetimebox('setValue', row.planArriveTime);
                                $('#draIsPlanAccounting').combobox('setValue', row.planIsWeight);
                                $('#draCreator').textbox('setValue', row.draCreatorName);
                                $('#draCreatorId').val(row.draCreatorId);
                                // setSkuList(row.draId);
                                $('#draId').val(row.draId);
                                $('#planId').val(row.planId);
                                $('#createId').val(row.createId);
                                $('#planPreCode').combogrid('setValues', row.planPreCode);
                                $('#skuDetail').combobox('setValue', row.skuCode);
                                $('#foreignName').combobox('setText', row.foreignName);
                                $('#proNum').numberbox('setValue', row.proNum);
                                initBtn(row.planServiceStatus);
                                getFileList(row);
                                if (row.planServiceStatus != '' && row.planServiceStatus != null) {
                                    $('#planServiceStatus').textbox('setValue', row.planServiceStatus == '1' ? '通过' : '不通过');
                                }
                                if (row.planTmStatus != '' && row.planTmStatus != null) {
                                    $('#planTmStatus').textbox('setValue', row.planTmStatus == '1' ? '通过' : '不通过');
                                }
                                if (row.planProdStatus != '' && row.planProdStatus != null) {
                                    $('#planProdStatus').textbox('setValue', row.planProdStatus == '1' ? '通过' : '不通过');
                                }
                                if (row.planStorStatus != '' && row.planStorStatus != null) {
                                    $('#planStorStatus').textbox('setValue', row.planStorStatus == '1' ? '通过' : '不通过');
                                }
                                if (row.planExcStatus != '' && row.planExcStatus != null) {
                                    $('#planExcStatus').textbox('setValue', row.planExcStatus == '1' ? '通过' : '不通过');
                                }
                                $('#draTransportName').combobox('setValue', row.draTransportId);
                            } else {
                                $.messager.alert('消息', '请选中一条数据');
                            }
                        }

                        function showDetail(index) {
                            if (index >= 0) {
                                // $('#dg').datagrid('clearChecked');
                                $('#dg').datagrid('selectRow', index);
                                $('#dg').datagrid('checkRow', index);
                            }
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            editrow(row);
                        }

                        function getGodNum(index) {
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            if (row.status != '1' && row.status != '5') {
                                $.messager.alert('消息', '只能选择有效和执行中状态！');
                                return;
                            }
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                async: false,
                                url: 'tm/plan/getGodNum?planId=' + row.planId,
                                contentType: "application/json",
                                success: function (data) {
                                    $.messager.alert('提示', data.msg);
                                    if (data.code == 60200) {
                                        selectList();
                                    }
                                }
                            })
                        }

                        function getTransportCode(index) {
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            if (row.status != '1' && row.status != '5') {
                                $.messager.alert('消息', '只能选择有效和执行中状态！');
                                return;
                            }
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                async: false,
                                url: 'tm/plan/getTransportCode?planId=' + row.planId,
                                contentType: "application/json",
                                success: function (data) {
                                    $.messager.alert('提示', data.msg);
                                    if (data.code == 60200) {
                                        selectList();
                                    }
                                }
                            })
                        }

                        function getEms(index) {
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            if (row.status != '1' && row.status != '5') {
                                // $.messager.alert('消息', '只能选择有效和执行中状态！');
                                // return;
                            }
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                async: false,
                                url: 'tm/plan/getEms?planId=' + row.planId,
                                contentType: "application/json",
                                success: function (data) {
                                    $.messager.alert('提示', data.msg);
                                    if (data.code == 60200) {
                                        selectList();
                                    }
                                }
                            })
                        }
                        function openTmUrl(index) {
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            if (row.transportCode == 0) {
                                $.messager.alert('消息', '运输单号不存在！');
                                return;
                            }
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                async: false,
                                url: 'tm/plan/openTmUrl?transportCode=' + row.transportCode + '&tmCarrierName=' + row.tmCarrierName,
                                contentType: "application/json",
                                success: function (data) {
                                    if (data.code == 60200) {
                                        window.open(data.data);
                                    } else {
                                        $.messager.alert('提示', data.msg);

                                    }
                                }
                            })
                        }
                        function openLifeUrl() {
                            var transportCode = $('#tmsValueSpan').html();
                            var tmCarrierName = $('#tmsCarrierValueSpan').html();
                            if (!transportCode || transportCode == '1') {
                                $.messager.alert('消息', '运输单号不存在！');
                                return;
                            }
                            $.ajax({
                                type: "get",
                                dataType: "json",
                                async: false,
                                url: 'tm/plan/openTmUrl?transportCode=' + transportCode + '&tmCarrierName=' + tmCarrierName,
                                contentType: "application/json",
                                success: function (data) {
                                    if (data.code == 60200) {
                                        window.open(data.data);
                                    } else {
                                        $.messager.alert('提示', data.msg);

                                    }
                                }
                            })
                        }

                        function openLifeCycle(index) {
                            const rows = $('#dg').datagrid('getRows');
                            let row = rows[index];
                            $('#lifeWindow').window('open');
                            $('#goodli').removeAttr("class");
                            if (row.status == '1') {
                                $('#lifeStatusValueSpan').html('有效；');
                            } else if (row.status == '2') {
                                $('#lifeStatusValueSpan').html('无效；');
                            } else if (row.status == '3') {
                                $('#lifeStatusValueSpan').html('已取消；');
                            } else if (row.status == '4') {
                                $('#lifeStatusValueSpan').html('已转卸；');
                            } else if (row.status == '5') {
                                $('#lifeStatusValueSpan').html('执行中；');
                            } else if (row.status == '6') {
                                $('#lifeStatusValueSpan').html('已完成；');
                            }
                            // $('#planli').css("color", " green").css("list-style-type", "circle");
                            $('#lifeCodeValueSpan').html(row.planCode + ';');
                            $('#lifeCusValueSpan').html(row.cusName + ';');
                            $('#lifePlanValueSpan').html(row.planName + ';');
                            $('#lifeSendDateValueSpan').html(row.sendDate + ';');
                            $('#lifeProNumValueSpan').html(row.proNum + ';');
                            $('#lifeCreatorValueSpan').html(row.createName + ';');
                            $('#lifeFactoryValueSpan').html(row.facName + ';');
                            $('#lifeStrideValueSpan').html(row.planStride + ';');
                            $('#lifeProNameValueSpan').html(row.proName + ';');

                            if (row.godNum > 0) {
                                $('#goodValueSpan').html(row.godNum + ';');
                                $('#goodStatusValueSpan').html('已完成;');
                                $('#goodNumValueSpan').html(row.proNum + ';');
                                $('#goodMatnrValueSpan').html(row.proName + ';');
                                // $('#goodli').css("color", "green").css("list-style-type", "circle");
                            } else {
                                $('#goodValueSpan').html('-;');
                                $('#goodStatusValueSpan').html('未开始;');
                                $('#goodNumValueSpan').html('-;');
                                $('#goodMatnrValueSpan').html('-;');
                                // $('#goodli').css("color", "").css("list-style-type", "circle");
                            }

                            if (row.transportCode > '1') {
                                $('#tmsValueSpan').html(row.transportCode + ';')
                                $('#tmsStatusValueSpan').html('已完成;');
                                $('#tmsCarrierValueSpan').html(row.tmCarrierName + ';')
                                $('#tmsDriverValueSpan').html(row.tmDriver + ';')
                                $('#tmsCarValueSpan').html(row.tmCar + ';')
                                // $('#tmsli').css("color", "green").css("list-style-type", "circle");
                            } else {
                                $('#tmsValueSpan').html('-;')
                                $('#tmsStatusValueSpan').html('未开始;');
                                $('#tmsCarrierValueSpan').html('-;')
                                $('#tmsDriverValueSpan').html('-;')
                                $('#tmsCarValueSpan').html('-;')
                                // $('#tmsli').css("color", "");
                            }

                            if (row.emsBillNum > '1') {
                                $('#emsValueSpan').html(row.emsBillNum + ';')
                            } else {
                                $('#emsValueSpan').html('-;')
                            }
                            if (row.emsOutTime > '0') {
                                $('#emsli').css("color", "green").css("list-style-type", "circle");
                            } else {
                                $('#emsli').css("color", "");
                            }
                            $('#emsInValueSpan').html(row.emsInTime ? row.emsInTime : '-;')
                            $('#emsOutValueSpan').html(row.emsOutTime ? row.emsOutTime : '-;')
                            $('#emsStatusValueSpan').html(row.emsOutTime > '0' ? '已完成' : '未完成;');
                            $('#tmsTareValueSpan').html(row.emsTare ? row.emsTare : '-;')
                            $('#tmsGrossValueSpan').html(row.emsGross ? row.emsGross : '-;')
                            $('#tmsNumValueSpan').html(row.emsNnum ? row.emsNnum : '-;')

                            // $li = $li + '客户：' + row.cusName + '；数量：' + row.proNum + '；完成时间：' + row.planServiceTime + '</li>';
                            // var $li = '<li style="list-style-type:circle">交货单：，状态：，完成时间：</li>';
                            // var $li = '<li>运输订单：状态：，罐箱号：，承运商：，车辆号：，司机：，完成时间：，车辆轨迹：</li>';
                            // var $li = ' <li>过磅单：状态：，一次计量时间：，二次计量时间：，皮重：，毛重：，净重：</li>';

                        }
                    </script>

                    <script>
                        function initBtn(status) {
                            if (status != '1') {
                                $('#tabs').tabs({
                                    tools: [{
                                        text: '保存',
                                        iconCls: 'icon-save',
                                        handler: function () {
                                            save('0');
                                        }
                                    }, {
                                        text: '提交',
                                        iconCls: 'icon-ok',
                                        handler: function () {
                                            $.messager.confirm('提示', '提交后无法再次编辑，确定要提交吗?',
                                                function (r) {
                                                    if (r) {
                                                        save('1');
                                                    }
                                                });
                                        }
                                    }]
                                })
                            } else {
                                $('#tabs').tabs({
                                    tools: null
                                })
                            }
                            $('#tabs').tabs('select', 0)
                        }
                        /**
                                                         *  按条件查询报价列表
                                                         */
                        function selectList() {
                            var startTime = $('#startTime').datebox('getValue')
                            var endTime = $('#endTime').datebox('getValue')
                            var status = $('#status').combobox('getValue');
                            var dg = $('#dg');
                            dg.datagrid('enableFilter');
                            dg.datagrid('load', {
                                startTime: startTime ? startTime : '',
                                endTime: endTime ? endTime : '',
                                status: status ? status : ''
                            });
                        }

                        function bindgrid() {
                            var startTime = $('#startTime').datebox('getValue')
                            var endTime = $('#endTime').datebox('getValue')
                            var status = $('#status').combobox('getValue');
                            $('#dg').datagrid({
                                title: '',
                                queryParams: {
                                    startTime: startTime,
                                    endTime: endTime,
                                    status: status
                                },
                                url: "tm/plan/selectList",
                                iconCls: 'icon-application',
                                width: getWidth(0.98),
                                height: 408,
                                showFooter: true,
                                nowrap: true,
                                filterDelay: 0,
                                rownumbers: true,
                                animate: false,
                                collapsible: false,
                                clientPaging: false,
                                remoteFilter: true,
                                singleSelect: false,
                                pagination: true,
                                remoteSort: true,
                                pageList: [10, 30, 50, 70, 100],
                                frozenColumns: [[{
                                    field: 'ck',
                                    checkbox: true,
                                    width: 100,
                                }, {
                                    field: 'planId',
                                    title: '计划id',
                                    sortable: true,
                                    hidden: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planCode',
                                    title: '计划编码',
                                    sortable: true,
                                    formatter: function (val, rec, index) {
                                        return '<a href="javascript:void(0)" onclick="showDetail(' + index +
                                            ')">' + (val ? val : '') + '</a>'
                                    }
                                },
                                {
                                    field: 'sendDate',
                                    title: '预计发货日期',
                                    sortable: true,
                                    formatter: function (val, rec, index) {
                                        return val
                                    }
                                }, {
                                    field: 'planName',
                                    title: '计划名称',
                                    sortable: true,
                                    width: 150,
                                    formatter: function (val, rec) {
                                        return '<span title="' + val + '">' + val + '</span>';
                                    }
                                },]],
                                columns: [[{
                                    field: 'status',
                                    title: '状态',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        switch (val) {
                                            case '0': return '未生效'; break;
                                            case '1': return '有效'; break;
                                            case '2': return '无效'; break;
                                            case '3': return '已取消'; break;
                                            case '4': return '已转卸'; break;
                                            case '5': return '执行中'; break;
                                            case '6': return '执行完成'; break;
                                            default: return '';
                                        };
                                    }
                                }, {
                                    field: 'planServiceStatus',
                                    title: '客服',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? (unescape(val == '1' ? '<span style="color:green;">通过</span>' : '<span style="color:red;">不通过</span>')) : ''
                                    }
                                }, {
                                    field: 'planTmStatus',
                                    title: '物流',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? (unescape(val == '1' ? '<span style="color:green;">通过</span>' : '<span style="color:red;">不通过</span>')) : ''
                                    }
                                }, {
                                    field: 'planStorStatus',
                                    title: '储运',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? (unescape(val == '1' ? '<span style="color:green;">通过</span>' : '<span style="color:red;">不通过</span>')) : ''
                                    }
                                }, {
                                    field: 'planProdStatus',
                                    title: '生产',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? (unescape(val == '1' ? '<span style="color:green;">通过</span>' : '<span style="color:red;">不通过</span>')) : ''
                                    }
                                }, {
                                    field: 'createName',
                                    title: '创建人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'godNum',
                                    title: '交货单号',
                                    sortable: true,
                                    width: 90,
                                    formatter: function (val, rec, index) {
                                        if (val == 0) {
                                            return '<a href="javascript:void(0)" onclick="getGodNum(' + index +
                                                ')">' + ('获取交货单') + '</a>'
                                        } else { return val }
                                    }
                                }, {
                                    field: 'transportCode',
                                    title: '运单号',
                                    sortable: true,
                                    width: 140,
                                    formatter: function (val, rec, index) {
                                        if (val == 0) {
                                            return '<a href="javascript:void(0)" onclick="getTransportCode(' + index +
                                                ')">' + ('获取运单号') + '</a>'
                                        } else {
                                            if (val == 1) {
                                                return ''
                                            } else {
                                                return val
                                            }
                                        }
                                    }
                                }, {
                                    field: 'facCode',
                                    title: '发货工厂编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'facName',
                                    title: '发货工厂名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'stoCode',
                                    title: '发货仓库编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'stoName',
                                    title: '发货仓库名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planReceiveName',
                                    title: '收货仓库',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'ordName',
                                    title: '订单类型名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'conCode',
                                    title: '合同编号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'conName',
                                    title: '合同名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'conFactoryName',
                                    title: '签约工厂',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planReachDate',
                                    title: '要求到货日期',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val
                                    }
                                }, {
                                    field: 'planStride',
                                    title: '是否跨公司',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val == '1' ? '是' : '否') : '';
                                    }
                                }, {
                                    field: 'cusCode',
                                    title: '客户编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'cusName',
                                    title: '客户名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'skuCode',
                                    title: 'SKU编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'skuDetail',
                                    title: 'SKU描述',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'skuNum',
                                    title: 'SKU数量',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'proCode',
                                    title: '产品编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'proName',
                                    title: '产品名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'proNum',
                                    title: '产品重量',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                    // }, {
                                    //     field: 'pakModeCode',
                                    //     title: '包装方式编码',
                                    //     sortable: true,
                                    //     formatter: function (val, rec) {
                                    //         return val ? unescape(val) : '';
                                    //     }
                                }, {
                                    field: 'pakModeName',
                                    title: '包装方式名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak1Code',
                                    title: '包装物-1编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak1Name',
                                    title: '包装物-1名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak1Num',
                                    title: '包装物-1数量',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak2Code',
                                    title: '包装物-2编码',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak2Name',
                                    title: '包装物-2名称',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'pak2Num',
                                    title: '包装物-2数量',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planFetchNum',
                                    title: '提单号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planCheckNum',
                                    title: '批号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planOrdRemark',
                                    title: '订单备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {
                                    field: 'planSendRemark',
                                    title: '送货单备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {
                                    field: 'planReceiveRemark',
                                    title: '收货地址',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planReceiveTel',
                                    title: '收货电话',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planArriveTime',
                                    title: '预计到厂时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planServiceName',
                                    title: '客服审核人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planServiceRemark',
                                    title: '客服备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {

                                    field: 'planServiceTime',
                                    title: '客服审核时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planTmName',
                                    title: '物流审核人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planTmRemark',
                                    title: '物流备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {

                                    field: 'planTmTime',
                                    title: '物流审核时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planProdName',
                                    title: '生产审核人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planProdRemark',
                                    title: '生产备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {

                                    field: 'planProdTime',
                                    title: '生产审核时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planStorName',
                                    title: '储运审核人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planStorRemark',
                                    title: '储运备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {

                                    field: 'planStorTime',
                                    title: '储运审核时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planExcName',
                                    title: '异常操作人',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'planExcRemark',
                                    title: '异常备注',
                                    sortable: true,
                                    width: 120,
                                    formatter: function (val, rec) {
                                        if (val) {
                                            return '<span title="' + val + '">' + val + '</span>';
                                        } else {
                                            return val;
                                        }
                                    }
                                }, {

                                    field: 'planExcTime',
                                    title: '异常审核时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'createTime',
                                    title: '创建时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'createId',
                                    title: '创建人',
                                    sortable: true,
                                    hidden: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'updateId',
                                    title: '修改人',
                                    sortable: true,
                                    hidden: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'planIsWeight',
                                    title: '是否控重',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val == '1' ? '是' : '否') : '';
                                    }
                                },
                                {

                                    field: 'draTransportId',
                                    title: '运输方式id',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {

                                    field: 'draTransportName',
                                    title: '运输方式',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                }, {
                                    field: 'draCreatorName',
                                    title: '业务员',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'deptName',
                                    title: '业务员部门',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'planReceiveCode',
                                    title: '收货仓库',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'planPreCode',
                                    title: '预装编号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'planPreNum',
                                    title: '库存占用量',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'foreignName',
                                    title: '外贸术语',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'tmTank',
                                    title: '罐号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'tmCarrierName',
                                    title: '承运商',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'tmDriver',
                                    title: '司机',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'tmCar',
                                    title: '车牌号',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'tmUrl1',
                                    title: '轨迹查看',
                                    width: 100,
                                    sortable: false,
                                    formatter: function (val, rec, index) {
                                        if (rec.tmCar) {
                                            return '<a href="javascript:void(0)" onclick="openTmUrl(' + index +
                                                ')">' + ('轨迹查看') + '</a>'
                                        }
                                    }
                                }, {
                                    field: 'emsBillNum',
                                    title: '过磅单号',
                                    sortable: true,
                                    width: 140,
                                    formatter: function (val, rec, index) {
                                        if (val == 0) {
                                            return '<a href="javascript:void(0)" onclick="getEms(' + index +
                                                ')">' + ('获取过磅单号') + '</a>'
                                        } else {
                                            if (val == 1) {
                                                return ''
                                            } else {
                                                return val
                                            }
                                        }
                                    }
                                },
                                {
                                    field: 'emsInTime',
                                    title: '一次计量时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'emsOutTime',
                                    title: '二次计量时间',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'emsGross',
                                    title: '毛重',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'emsTare',
                                    title: '皮重',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'emsNnum',
                                    title: '净重',
                                    sortable: true,
                                    formatter: function (val, rec) {
                                        return val ? unescape(val) : '';
                                    }
                                },
                                {
                                    field: 'lifeCycle',
                                    title: '生命周期',
                                    width: 100,
                                    sortable: false,
                                    formatter: function (val, rec, index) {
                                        if (rec.status > 0) {
                                            return '<a href="javascript:void(0)" onclick="openLifeCycle(' + index +
                                                ')">' + ('生命周期') + '</a>'
                                        }
                                    }
                                }
                                ]],
                                toolbar: [{
                                    text: '增加',
                                    iconCls: 'icon-add',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    handler: function () {
                                        $('#dg').datagrid('clearSelections');
                                        $('#fm').form('clear');
                                        $('#addWindow').window('open');
                                        initFile([]);
                                        initBtn('0'); initYZ();
                                        $('#tabs').tabs('select', 0)
                                    }
                                },
                                    '-',
                                {
                                    text: '编辑',
                                    iconCls: 'icon-edit',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }

                                        //编辑用户
                                        var row = $('#dg').datagrid('getSelected');
                                        if (row) {
                                            editrow(row)
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '撤回',
                                    iconCls: 'icon-undo',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }
                                        $.messager.confirm('提示', '确定要撤回吗?', function (r) {
                                            if (r) {

                                                var row = $('#dg').datagrid('getSelected');
                                                if (row) {
                                                    if (row.planServiceStatus == 0) {
                                                        $.messager.alert('消息', '未提交无需撤回！');
                                                        return;
                                                    }
                                                    if (row.planProdStatus == 1) {
                                                        $.messager.alert('消息', '生产已审核通过，无法撤回！');
                                                        return;
                                                    }
                                                    if (row.planTmStatus == 1) {
                                                        $.messager.alert('消息', '物流已审核通过，无法撤回！');
                                                        return;
                                                    }
                                                    if (row.planStorStatus == 1) {
                                                        $.messager.alert('消息', '储运已审核通过，无法撤回！');
                                                        return;
                                                    }
                                                    back(row)
                                                } else {
                                                    $.messager.alert('消息', '请选中一条数据');
                                                }
                                            }
                                        })
                                    }
                                },
                                    '-',
                                {
                                    text: '客服审核',
                                    iconCls: 'icon-ok',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 0) {
                                            $('#checkWindow').dialog('open');
                                            $('#checkDept').val('客服');
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '物流审核',
                                    iconCls: 'icon-ok',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('物流') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 0) {
                                            $('#checkWindow').dialog('open');
                                            $('#checkDept').val('物流');
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '生产审核',
                                    iconCls: 'icon-ok',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('生产') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 0) {
                                            $('#checkWindow').dialog('open');
                                            $('#checkDept').val('生产');
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '储运审核',
                                    iconCls: 'icon-ok',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('储运') >= 0 ? false : true) : true,
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 0) {
                                            $('#checkWindow').dialog('open');
                                            $('#checkDept').val('储运');
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '删除',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    iconCls: 'icon-remove',
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }

                                        var row = $('#dg').datagrid('getSelected');
                                        if (row) {
                                            if (row.status > 0) {
                                                $.messager.alert('消息', '已提交，不可删除！');
                                                return;
                                            }
                                            $.messager.confirm('提示', '确定要删除这个吗?', function (r) {
                                                if (r) {
                                                    del(row);
                                                }
                                            });
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '取消',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    iconCls: 'icon-no',
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }

                                        var row = $('#dg').datagrid('getSelected');
                                        if (row) {
                                            if (row.status != '1' && row.status != '5') {
                                                $.messager.alert('消息', '只可取消有效、执行中状态计划！');
                                                return;
                                            }
                                            $.messager.confirm('提示', '确定要取消吗?', function (r) {
                                                if (r) {
                                                    $('#planCodeSpan').html(row.planCode);
                                                    $('#planNameSpan').html(row.planName);
                                                    $('#excDept').val('cansel');
                                                    $('#excWindow').dialog('open')
                                                }
                                            });
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '转卸',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    iconCls: 'icon-cut',
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }

                                        var row = $('#dg').datagrid('getSelected');
                                        if (row) {
                                            if (row.status != '1' && row.status != '6') {
                                                $.messager.alert('消息', '只可转卸有效、已完成状态计划！');
                                                return;
                                            }
                                            $.messager.confirm('提示', '确定要转卸吗?', function (r) {
                                                if (r) {
                                                    $('#planCodeSpan').html(row.planCode);
                                                    $('#planNameSpan').html(row.planName);
                                                    $('#excDept').val('transfer');
                                                    $('#excWindow').dialog('open')
                                                }
                                            });
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                },
                                    '-',
                                {
                                    text: '复制',
                                    disabled: globalePermisson ? (globalePermisson.get('tm/plan').indexOf('客服') >= 0 ? false : true) : true,
                                    iconCls: 'icon-mini-add',
                                    handler: function () {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 1) {
                                            $.messager.alert('消息', '只可选择一条数据！');
                                            return;
                                        }

                                        var row = $('#dg').datagrid('getSelected');
                                        if (row) {
                                            $.messager.confirm('提示', '确定要复制吗?', function (r) {
                                                if (r) {
                                                    $.ajax({
                                                        type: "post",
                                                        async: false,
                                                        url: 'tm/plan/copy',
                                                        //                dataType: "xml",				
                                                        data: { planId: row.planId },
                                                        success: function (data) {
                                                            $.messager.alert('消息', data.msg);
                                                            selectList();
                                                        },
                                                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                                                            $.messager.alert('消息', errorThrown);
                                                        }
                                                    });
                                                }
                                            });
                                        } else {
                                            $.messager.alert('消息', '请选中一条数据');
                                        }
                                    }
                                }],
                                onLoadSuccess: function () {
                                },
                                onDblClickRow: function () {
                                    var row = $('#dg').datagrid('getSelected');
                                    editrow(row);
                                }
                            });
                            $('#dg').datagrid('enableFilter');
                        }


                        // 导出为Excel
                        function exportList() {
                            let startTime = $('#startTime').datebox('getValue')
                            let endTime = $('#endTime').datebox('getValue')
                            let status = $('#status').combobox('getValue')
                            var form = [];
                            form.push('startTime=' + (startTime ? startTime : ''));
                            form.push('endTime=' + (endTime ? endTime : ''));
                            form.push('status=' + (status ? status : ''));
                            let url = "api/tm/plan/export"
                            let xhr = new XMLHttpRequest()
                            xhr.open('POST', url, true)
                            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                            xhr.setRequestHeader('token', localStorage.getItem('token'));
                            xhr.setRequestHeader('userType', localStorage.getItem('userType'));
                            xhr.responseType = 'blob'
                            xhr.onload = function () {
                                if (this.status == 200) {
                                    let blob = this.response
                                    let reader = new FileReader()
                                    reader.readAsDataURL(blob)
                                    reader.onload = function (e) {
                                        let a = document.createElement('a')
                                        a.download = '排货计划' + new Date().toLocaleDateString() + '-' + new Date().toLocaleTimeString() + '.xlsx'
                                        a.href = e.target.result
                                        $('body').append(a)
                                        a.click()
                                        $(a).remove()
                                    }
                                }
                            }
                            xhr.send(form.join('&'))
                        }
                    </script>

                    <script>
                        //取消
                        function cansel(row) {
                            var remark = $('#excRemark').textbox('getValue');
                            $.ajax({
                                type: "post",
                                async: false,
                                url: 'tm/plan/cansel',
                                //                dataType: "xml",				
                                data: { planId: row.planId, planExcRemark: remark },
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                    selectList();
                                    $('#excWindow').dialog('close')
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }

                        //异常保存
                        function excSave() {
                            var remark = $('#excRemark').textbox('getValue');
                            if (!remark) {
                                $.messager.alert('提示', '请录入备注!');
                                return;
                            }
                            var row = $('#dg').datagrid('getSelected');
                            var excDept = $('#excDept').val();
                            if (excDept == 'cansel') {
                                cansel(row)
                            }
                            if (excDept == 'transfer') {
                                $.messager.confirm('提示', '转卸后是否复制生成新的计划？',
                                    function (r) {
                                        if (r) {
                                            transfercopy(row)
                                        }
                                        else {
                                            transfer(row)
                                        }
                                    })
                            }
                        }

                        //初始化审核框
                        function initCheck() {

                        }


                        //批量审核保存
                        function checkSave() {
                            $.messager.confirm('提示', '确认审核？',
                                function (r) {
                                    if (r) {
                                        var rows = $('#dg').datagrid('getChecked');
                                        if (rows && rows.length > 0) {
                                            for (var row of rows) {
                                                if (row.status > 2) {
                                                    $.messager.alert('提示', '只能审核未生效、有效、失效计划，' + row.planName + '状态并非未生效、有效、失效，请重新选择!');
                                                    return;
                                                }
                                                if ($('#checkDept').val() != '客服') {
                                                    if (row.planServiceStatus != 1) {
                                                        $.messager.alert('提示', row.planName + '客服未审核通过，请重新选择!');
                                                        return;
                                                    }
                                                } else {
                                                    if ($('#checkStatus').combobox('getValue') == '0' && row.planServiceStatus == '1') {
                                                        $.messager.alert('提示', row.planName + '已通过，无法修改为不通过，请点击撤回!');
                                                        return;
                                                    }
                                                    row.planServiceStatus = $('#checkStatus').combobox('getValue');
                                                }
                                            }
                                            // for (var row of rows) {
                                            // }
                                            var status = $('#checkStatus').combobox('getValue');
                                            var remark = $('#checkRemark').textbox('getValue');
                                            if (status == '0' && !remark) {
                                                $.messager.alert('提示', '请录入备注!');
                                                return;
                                            }
                                            var model = {
                                                rows: rows, checkDept: $('#checkDept').val(),
                                                status: $('#checkStatus').combobox('getValue'),
                                                remark: $('#checkRemark').textbox('getValue')
                                            };

                                            $.ajax({
                                                type: "post",
                                                async: false,
                                                dataType: "json",
                                                url: 'tm/plan/check',
                                                data: JSON.stringify(model),
                                                contentType: "application/json",
                                                success: function (data) {
                                                    $.messager.alert('提示', data.msg);
                                                    if (data.code == 60200) {
                                                        $('#checkWindow').dialog('close');
                                                        selectList();
                                                    }
                                                }
                                            })
                                        } else {
                                            $.messager.alert('提示', '请选择数据');
                                        }
                                    }
                                });
                        }

                        //转卸
                        function transfer(row) {
                            var remark = $('#excRemark').textbox('getValue');
                            $.ajax({
                                type: "post",
                                async: false,
                                url: 'tm/plan/transfer',
                                //                dataType: "xml",				
                                data: { planId: row.planId, planExcRemark: remark },
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                    selectList();
                                    $('#excWindow').dialog('close')
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }

                        //转卸
                        function transfercopy(row) {
                            var remark = $('#excRemark').textbox('getValue');
                            $.ajax({
                                type: "post",
                                async: false,
                                url: 'tm/plan/transfercopy',
                                //                dataType: "xml",				
                                data: { planId: row.planId, planExcRemark: remark },
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                    selectList();
                                    $('#excWindow').dialog('close')
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            });
                        }
                    </script>

                    <script>
                        //选择合同
                        function selectContractList() {
                            let dg = $('#saleContractDataGrid');
                            dg.datagrid('enableFilter');
                            dg.datagrid('load', {
                                startTime: $('#startPlanTime').datebox('getValue') ? $('#startPlanTime').datebox('getValue') : '',
                                endTime: $('#endPlanTime').datebox('getValue') ? $('#endPlanTime').datebox('getValue') : '',
                                status: '1'
                            })
                        }

                        function bindContractGrid() {
                            let startTime = $('#startPlanTime').datebox('getValue')
                            let endTime = $('#endPlanTime').datebox('getValue')
                            $('#saleContractDataGrid').datagrid(
                                {
                                    title: '',
                                    queryParams: {
                                        startTime: startTime ? startTime : '',
                                        endTime: endTime ? endTime : '',
                                        status: '1'
                                    },
                                    url: "tm/plan/selectContractList",
                                    iconCls: 'icon-application',
                                    width: 860,
                                    height: 380,
                                    filterDelay: 0,
                                    nowrap: true,
                                    rownumbers: true,
                                    animate: false,
                                    collapsible: false,
                                    clientPaging: false,
                                    remoteFilter: true,
                                    singleSelect: true,
                                    pagination: true,
                                    remoteSort: true,
                                    frozenColumns: [[{
                                        field: 'sigId',
                                        title: '签署id',
                                        sortable: true,
                                        hidden: true,
                                        formatter: function (val, rec) {
                                            return val ? unescape(val) : '';
                                        }
                                    }, {
                                        field: 'draId',
                                        title: '合同起草id',
                                        sortable: true,
                                        hidden: true,
                                        formatter: function (val, rec) {
                                            return val ? unescape(val) : '';
                                        }
                                    }, {
                                        field: 'draCode',
                                        title: '合同编号',
                                        sortable: true,
                                        formatter: function (val, rec, index) {
                                            let valTem = val ? val : '--'
                                            return valTem;
                                        }
                                    },
                                    {
                                        field: 'draName',
                                        title: '合同名称',
                                        sortable: true,
                                        formatter: function (val, rec, index) {
                                            return val
                                        }
                                    },]],
                                    columns: [
                                        [{
                                            field: 'infCode',
                                            title: '客户编码',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infName',
                                            title: '客户名称',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'draMoney',
                                            title: '合同金额',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'draCurrency',
                                            title: '合同币种',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        },
                                        {
                                            field: 'poNumber',
                                            title: '采购订单号',
                                            sortable: true,
                                            formatter: function (val, rec, index) {
                                                let valTem = val ? val : '--'
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'createTime',
                                            title: '创建时间',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'createName',
                                            title: '创建人',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'updateName',
                                            title: '更新人',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'updateTime',
                                            title: '更新时间',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'remark',
                                            title: '备注',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }]],
                                    toolbar: [{
                                        text: '加入',
                                        iconCls: 'icon-ok',
                                        handler: function () {
                                            //获取选择的方案内容
                                            addContract();
                                        }
                                    }],
                                    onLoadSuccess: function () {
                                    },
                                });
                            $('#saleContractDataGrid').datagrid('enableFilter');
                        }

                        //根据选择的合同初始化数据
                        function addContract() {
                            var row = $('#saleContractDataGrid').datagrid('getSelected');
                            if (row) {
                                $('#conCode').textbox('setValue', row.draCode);
                                $('#conName').textbox('setValue', row.draName);
                                $('#draId').val(row.draId);
                                setSkuList(row.draId);
                                $('#selectContractWindow').window('close');
                            } else {
                                $.messager.alert('消息', '请选择一条数据');
                            }
                        }

                        var skus = [];
                        //获取sku列表
                        function setSkuList(draId) {
                            $.ajax({
                                type: 'get',
                                url: 'sale/contract/draft/selectInfor?id=' + draId,
                                async: false,
                                success: function (data) {
                                    if (data.code == 60200) {
                                        var result = data.data;
                                        $('#cusCode').textbox('setValue', result.infCode);
                                        $('#cusName').textbox('setValue', result.infName);
                                        $('#draIsPlanAccounting').combobox('setValue', result.draIsPlanAccounting);
                                        $('#draTransportName').combobox('setValue', result.draTransportId);
                                        $('#draCreator').textbox('setValue', result.createName);
                                        $('#draCreatorId').val(result.createId);
                                        $('#planReceiveRemark').textbox('setValue', result.draAddressDetail);
                                        $('#foreignName').combobox('setText', result.draTerminologyForeignTradeName);
                                        let draOrgCode = result.draOrgName;
                                        let wERKS = "";
                                        if (draOrgCode.indexOf('海科新源') != -1) {
                                            wERKS = '1000'
                                        } else if (draOrgCode.indexOf('江苏思派') != -1) {
                                            wERKS = '1010'
                                        } else if (draOrgCode.indexOf('欧洲') != -1) {
                                            wERKS = '2010'
                                        } else if (draOrgCode.indexOf('湖北材料') != -1) {
                                            wERKS = '1020'
                                        } else if (draOrgCode.indexOf('湖北浩科') != -1) {
                                            wERKS = '1030'
                                        } else if (draOrgCode.indexOf('新蔚源') != -1) {
                                            wERKS = '1040'
                                        } else if (draOrgCode.indexOf('上海宝山') != -1) {
                                            wERKS = '2000'
                                        };
                                        if (wERKS == $('#facCode').combobox('getValue')) {
                                            $('#planStride').combobox('setValue', 0)
                                            $('#ordCode').combobox('setValue', 1)
                                        } else {
                                            $('#planStride').combobox('setValue', 1)
                                            $('#ordCode').combobox('setValue', 2)
                                        }
                                        $('#conFactoryCode').combobox('setValue', wERKS);
                                        skus = [];
                                        for (var item of result.productModels) {
                                            var json = {};
                                            json.id = item.skuNum;
                                            json.text = item.skuDescription;
                                            json.pakModeCode = item.draPackageId;
                                            skus.push(json);
                                        }
                                        $('#skuDetail').combobox('loadData', skus);
                                        if (skus.length > 0) {
                                            $('#skuDetail').combobox('setValue', skus[0].id);
                                        } else {
                                            $.messager.alert('提示', '不存在sku！');
                                        }
                                    }
                                }
                            })
                        }

                        //初始化sku信息
                        function initSKU(value) {
                            if (!value) {
                                return;
                            }
                            $('#skuCode').textbox('setValue', value);
                            if (!$('#facCode').combobox('getValue')) {
                                $.messager.alert('消息', '请选择发货工厂!');
                                return;
                            }
                            $('#pakModeCode').combobox('setValue', '');
                            console.log('skus,value', skus, value);
                            for (var sku of skus) {
                                if (sku.id == value) {
                                    $('#pakModeCode').combobox('setValue', sku.pakModeCode);
                                }
                            }
                            //初始化
                            $('#proCode').textbox('setValue', '');
                            $('#proName').textbox('setValue', '');
                            $('#proUnitNum').val(0);
                            $('#pak1Code').textbox('setValue', '');
                            $('#pak1Name').textbox('setValue', '');
                            $('#pak1UnitNum').val(0);
                            $('#pak2Code').textbox('setValue', '');
                            $('#pak2Name').textbox('setValue', '');
                            $('#pak2UnitNum').val(0);
                            initSKUWeight();

                            $.ajax({
                                type: 'get',
                                url: 'sale/sku/master/selectInfor?skuNum=' + value + '&skuFactory=' + $('#facCode').combobox('getValue'),
                                async: false,
                                success: function (data) {
                                    if (data.code == 60200) {
                                        var result = data.data.skuItems;
                                        if (result[0]) {
                                            $('#proCode').textbox('setValue', result[0].itemNum);
                                            $('#proName').textbox('setValue', result[0].itemDescription);
                                            $('#proUnitNum').val(result[0].itemCount);
                                        }
                                        if (result[1]) {
                                            $('#pak1Code').textbox('setValue', result[1].itemNum);
                                            $('#pak1Name').textbox('setValue', result[1].itemDescription);
                                            $('#pak1UnitNum').val(result[1].itemCount);
                                        }
                                        if (result[2]) {
                                            $('#pak2Code').textbox('setValue', result[2].itemNum);
                                            $('#pak2Name').textbox('setValue', result[2].itemDescription);
                                            $('#pak2UnitNum').val(result[2].itemCount);
                                        }
                                        initSKUWeight();
                                    }
                                }
                            })
                        }

                        //计算数量
                        function initSKUWeight() {
                            $('#proNum').numberbox('setValue', $('#proUnitNum').val() * $('#skuNum').numberbox('getValue'));
                            $('#pak1Num').numberbox('setValue', $('#pak1UnitNum').val() * $('#skuNum').numberbox('getValue'));
                            $('#pak2Num').numberbox('setValue', $('#pak2UnitNum').val() * $('#skuNum').numberbox('getValue'));
                        }
                    </script>

                    <script>
                        //选择客户
                        function suppliesDatagird() {
                            //         $('#startSupplyTime').datebox('setValue', getBeforeCurrentDate30Days());
                            //         $('#endSupplyTime').datebox('setValue', getNowFormatDate());
                            let supplyDataGrid = $('#customDataGrid');
                            supplyDataGrid.datagrid({
                                queryParams: {
                                    //                 startTime: $('#startTime').datebox('getValue') ? $('#startTime').datebox('getValue') : '',
                                    //                 endTime: $('#endTime').datebox('getValue') ? $('#endTime').datebox('getValue') : ''
                                    // infApprovalStatus: '1'
                                },
                                fitColumns: true,
                                url: 'supply/info/selectList',
                                iconCls: 'icon-application',
                                clientPaging: false,
                                checkOnSelect: true,
                                remoteFilter: true,
                                filterDelay: 0,
                                width: 860,
                                height: 380,
                                nowrap: true,
                                rownumbers: true,
                                animate: false,
                                collapsible: false,
                                singleSelect: true,
                                // pageSize: 6,
                                // pageList: [6, 18, 28, 50],
                                remoteSort: true,
                                pagination: true,
                                frozenColumns: [[
                                    {
                                        field: 'infId',
                                        title: '供应商id',
                                        hidden: true,
                                        sortable: true,
                                        width: 100,
                                        formatter: function (val, rec) {
                                            return unescape(val ? val : '')
                                        }
                                    },
                                    {
                                        field: 'gramId',
                                        title: '方案id',
                                        hidden: true,
                                        sortable: true,
                                        width: 100,
                                        formatter: function (val, rec) {
                                            return unescape(val ? val : '')
                                        }
                                    },
                                    {
                                        field: 'infCode',
                                        title: '客户编码',
                                        sortable: true,
                                        formatter: function (val, rec, index) {
                                            return unescape(val ? val : '')
                                        }
                                    }, {
                                        field: 'infName',
                                        title: '客户名称',
                                        sortable: true,
                                        formatter: function (val, rec) {
                                            return unescape(val ? val : '')
                                        }
                                    },]],
                                columns: [
                                    [
                                        {
                                            field: 'infCreditCode',
                                            title: '社会信用代码',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infCountry',
                                            title: '国家',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infProvince',
                                            title: '地区',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infCity',
                                            title: '地市',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infAddress',
                                            title: '单位地址',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infMobile',
                                            title: '手机',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'infContactsName',
                                            title: '联系人姓名',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }
                                    ]
                                ],
                                toolbar: [{
                                    text: '添加',
                                    iconCls: 'icon-ok',
                                    handler: function () {
                                        addCustom();
                                    }
                                }],
                                onLoadSuccess: function () { },
                            })
                            supplyDataGrid.datagrid('enableFilter');
                        }

                        function addCustom() {
                            var row = $('#customDataGrid').datagrid('getSelected');
                            if (row) {
                                $('#cusCode').textbox('setValue', row.infCode);
                                $('#cusName').textbox('setValue', row.infName);
                                $('#selectCustomWindow').window('close');
                            } else {
                                $.messager.alert('消息', '请选择一条数据');
                            }
                        }

                        // 设置待选物资列表dataGrid
                        function setMMsDataGrid() {
                            let mmDataGrid = $('#skuDataGrid');
                            mmDataGrid.datagrid(
                                {
                                    title: '',
                                    url: "sale/sku/master/selectListWithWeight",
                                    iconCls: 'icon-application',
                                    clientPaging: false,
                                    remoteFilter: true,
                                    filterDelay: 0,
                                    width: 860,
                                    height: 380,
                                    nowrap: true,
                                    rownumbers: true,
                                    animate: false,
                                    collapsible: false,
                                    singleSelect: true,
                                    pageSize: 10,
                                    // remoteSort: false,
                                    pagination: true,
                                    columns: [
                                        [{
                                            field: 'mmTag',
                                            title: '物料标签',
                                            sortable: true,
                                            hidden: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        },
                                        {
                                            field: 'skuNum',
                                            title: 'SKU编码',
                                            sortable: true,
                                            width: 150,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'skuDescription',
                                            title: 'sku描述',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'skuUnit',
                                            title: '单位',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'skuFactory',
                                            title: '工厂',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }, {
                                            field: 'skuFactoryDescription',
                                            title: '工厂描述',
                                            sortable: true,
                                            formatter: function (val, rec) {
                                                return val ? unescape(val) : '';
                                            }
                                        }]],
                                    toolbar: [
                                        {
                                            text: '添加',
                                            iconCls: 'icon-ok',
                                            handler: function () {
                                                addSku()
                                            }
                                        }],
                                    onLoadSuccess: function () {
                                    },
                                }
                            )
                            mmDataGrid.datagrid('enableFilter')
                        }

                        function addSku() {
                            var row = $('#skuDataGrid').datagrid('getSelected');
                            if (row) {
                                var skus = [];
                                var json = {};
                                json.id = row.skuNum;
                                json.text = row.skuDescription;
                                json.pakModeCode = row.draPackageId;
                                skus.push(json);
                                $('#skuDetail').combobox('loadData', skus);
                                $('#skuDetail').combobox('setValue', row.skuNum);
                                initSKU(row.skuNum);
                                $('#selectSkuWindow').window('close');
                            } else {
                                $.messager.alert('消息', '请选择一条数据');
                            }

                        }
                    </script>

                    <style scoped="scoped">
                        .textbox {
                            height: 20px;
                            margin: 0;
                            padding: 0 2px;
                            box-sizing: content-box;
                        }

                        /*.table tr {
        height: 15px;
    }*/
                    </style>
                    <div class="query_criteria" id="query_criteria">
                        <div style="margin: 5px 0px">
                            <%-- 搜索框 --%>
                                <label style="font-size: 12px;">预计发货时间：</label> <input class="easyui-datebox"
                                    name="startTime" id="startTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
                                    class="easyui-datebox" name="endTime" id="endTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    style="width: 150px" /> <label
                                    style="margin-left: 20px; font-size: 12px;">状态：</label>
                                <input class="easyui-combobox" id="status" name="status" style="width: 80px;"
                                    data-options="valueField: 'value',editable:false,
						textField: 'label',panelHeight:'auto',data: [{
							label: '全部',
							value: '',
							selected:true
						},{
							label: '未生效',
							value: '0'
						},{
							label: '有效',
							value: '1'
						},{
							label: '无效',
							value: '2'
						},{
							label: '已取消',
							value: '3'
						},{
							label: '已转卸',
							value: '4'
						},{
							label: '执行中',
							value: '5'
						},{
							label: '执行完成',
							value: '6'
						}]">
                                </select> <a id="search" style="margin-left: 30px" href="javascript:void(0)"
                                    class="easyui-linkbutton" data-options="iconCls:'icon-search'"
                                    onclick="selectList()">查询</a> <a id="export" href="javascript:void(0)"
                                    class="easyui-linkbutton" data-options="iconCls:'icon-export'"
                                    onclick="exportList()">导出</a>
                        </div>

                        <table id="dg"></table>

                        <div id="selectContractWindow" closed="true" modal="true" class="easyui-window" title="选择销售合同"
                            style="width: 900px; height: 460px; padding: 5px;">
                            <%-- 搜索框 --%>
                                <label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox"
                                    name="startPlanTime" id="startPlanTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
                                    class="easyui-datebox" name="endPlanTime" id="endPlanTime"
                                    data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                    style="width: 150px" /> </select> <a id="search" style="margin-left: 30px"
                                    href="javascript:void(0)" class="easyui-linkbutton"
                                    data-options="iconCls:'icon-search'" onclick="selectContractList()">查询</a>
                                <table id="saleContractDataGrid"></table>
                        </div>

                        <div id="selectCustomWindow" closed="true" modal="true" class="easyui-window" title="选择客户"
                            style="width: 900px; height: 450px; padding: 5px;">
                            <table id="customDataGrid"></table>
                        </div>

                        <div class="easyui-dialog" id="checkWindow" title="批量审核"
                            style="width: 500px;;height:300px;padding:5px" data-options="  closed:true,  buttons: [{
                                text:'保存',
                                handler:function(){
                                    checkSave();
                                }
                            },{
                                text:'关闭',
                                handler:function(){
                                    $('#checkWindow').dialog('close')
                                }
                            }],                   
                        onResize:function(){
                            $(this).dialog('center'); 
                        }">
                            <table>
                                <tr>
                                    <td>是否通过:</td>
                                    <td>
                                        <div> <select class="easyui-combobox" id="checkStatus" style="width: 120px;"
                                                data-options="required:true,editable:false">
                                                <option value="1">通过</option>
                                                <option value="0">不通过</option>
                                            </select></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>备注：</td>
                                    <td><input type="hidden" id="checkDept" />
                                        <input id="checkRemark" style="width: 350px; height:180px"
                                            class="easyui-textbox" data-options="multiline:true" />
                                    </td>
                                </tr>
                            </table>
                        </div>

                        <div class="easyui-dialog" id="excWindow" title="异常操作"
                            style="width: 500px;;height:360px;padding:5px" data-options="closed:true,  buttons: [{
                                text:'保存',
                                handler:function(){
                                    excSave();
                                }
                            },{
                                text:'关闭',
                                handler:function(){
                                    $('#excWindow').dialog('close')
                                }
                            }],                   
                        onResize:function(){
                            $(this).dialog('center'); 
                        }">
                            <table>
                                <tr>
                                    <td>计划编码：</td>
                                    <td><span id="planCodeSpan"></span></td>
                                </tr>
                                <tr>
                                    <td>计划名称：</td>
                                    <td><span id="planNameSpan"></span></td>
                                </tr>
                                <tr>
                                    <td>异常原因：</td>
                                    <td><input type="hidden" id="excDept" />
                                        <input id="excRemark" style="width: 350px; height:180px" class="easyui-textbox"
                                            data-options="multiline:true" />
                                    </td>
                                </tr>
                            </table>
                        </div>

                        <div class="easyui-dialog" id="lifeWindow" title="生命周期" data-options="closed:true"
                            style="width: 500px;;height:380px;padding:5px">
                            <div id="tabs" class="easyui-tabs" style="width: 450px; height: 330px">
                                <div title="排货计划" style="padding: 5px 0 5px 0;">
                                    <div style="padding: 10px 0 0 10px;font-size: 14px;">
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeCodeNameSpan">计划编码：</span>
                                        <span id="lifeCodeValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifePlanNameSpan">计划名称：</span>
                                        <span id="lifePlanValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeStatusNameSpan">状态：</span>
                                        <span id="lifeStatusValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeCusNameSpan">客户：</span>
                                        <span id="lifeCusValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeSendDateNameSpan">预计发货日期：</span>
                                        <span id="lifeSendDateValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeFactorySpan">发货工厂：</span>
                                        <span id="lifeFactoryValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeStrideSpan">是否跨公司：</span>
                                        <span id="lifeStrideValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeProNameSpan">产品名称：</span>
                                        <span id="lifeProNameValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeProNumSpan">产品重量：</span>
                                        <span id="lifeProNumValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="lifeCreatorSpan">创建人：</span>
                                        <span id="lifeCreatorValueSpan"></span>
                                    </div>
                                    <!-- <ul id="lifeUl">
                                        <li id="planli">

                                        </li>
                                        <li id="goodli">

                                        </li>
                                        <li id="tmsli">

                                        </li>
                                        <li id="emsli"> </li>
                                    </ul> -->
                                </div>
                                <div title="交货单" style="padding: 5px 0 5px 0;">
                                    <div style="padding: 10px 0 0 10px;font-size: 14px;">
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="goodNameSpan">交货单：</span>
                                        <span id="goodValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="goodStatusNameSpan">状态：</span>
                                        <span id="goodStatusValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="goodMatnrNameSpan">物料：</span>
                                        <span id="goodMatnrValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="goodNumNameSpan">数量：</span>
                                        <span id="goodNumValueSpan"></span>
                                        <div style="clear:both"></div>
                                    </div>
                                </div>
                                <div title="运输单" style="padding: 5px 0 5px 0;">
                                    <div style="padding: 10px 0 0 10px;font-size: 14px;">
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsNameSpan">运输订单：</span>
                                        <span id="tmsValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsStatusNameSpan">状态：</span>
                                        <span id="tmsStatusValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsCarrierNameSpan">承运商：</span>
                                        <span id="tmsCarrierValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsDriverNameSpan">司机：</span>
                                        <span id="tmsDriverValueSpan" style="width: 50px;  "></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsCarNameSpan">车牌号：</span>
                                        <span id="tmsCarValueSpan" style="width: 70px; "></span>
                                        <span style="font-weight: bold;"><a href="javascript:void"
                                                onclick="openLifeUrl()">车辆轨迹</a></span>
                                        <div style="clear:both"></div>
                                    </div>
                                </div>
                                <div title="过磅单" style="padding: 5px 0 5px 0;">
                                    <div style="padding: 10px 0 0 10px;font-size: 14px;">
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="emsNameSpan">过磅单：</span>
                                        <span id="emsValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="emsStatusNameSpan">状态：</span>
                                        <span id="emsStatusValueSpan"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="emsInNameSpan">入场时间：</span>
                                        <span id="emsInValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="emsOutNameSpan">出场时间：</span>
                                        <span id="emsOutValueSpan" style="width: 140px;"></span>
                                        <br>
                                        <div style="clear:both"></div>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsTareNameSpan">皮重：</span>
                                        <span id="tmsTareValueSpan" style="width: 50px;  "></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsGrossNameSpan">毛重：</span>
                                        <span id="tmsGrossValueSpan" style="width: 50px;  "></span>
                                        <br>
                                        <span style="font-weight: bold;width: 100px;display: inline-block;"
                                            id="tmsNumNameSpan">净重：</span>
                                        <span id="tmsNumValueSpan" style="width: 50px;  "></span>
                                    </div>
                                </div>
                            </div>

                            <div id="selectSkuWindow" closed="true" modal="true" class="easyui-window" title="选择SKU"
                                style="width: 900px; height: 450px; padding: 5px;">
                                <table id="skuDataGrid"></table>
                            </div>

                            <div id="addWindow" class="easyui-window" closed="true" modal="true" title="详细信息"
                                style="width: 900px; height: 400px; padding: 5px 5px">
                                <div id="tabs" class="easyui-tabs" style="width: 875px; height: 350px">
                                    <div title="基本信息" style="padding: 5px;">
                                        <form id="fm" class="ssec-form">
                                            <table class="table">
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">计划编码：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input type="hidden" id="planId" />
                                                            <input type="hidden" id="createId" />
                                                            <input id="planCode" name="planCode" class="easyui-textbox"
                                                                data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">计划名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planName" name="planName" class="easyui-textbox"
                                                                data-options="required:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">预计发货日期：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="sendDate" name="sendDate" class="easyui-datebox"
                                                                data-options="required:true,editable:false" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">发货工厂：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="facCode" class="easyui-combobox" data-options="required:true,url:'sysDict/queryItemByTypeName?dicName=交货工厂',method:'get',
					                                                          valueField:'dicValue',textField:'dicName',panelHeight:'auto',editable:false,
                                                                              onChange: function(newValue,oldValue){ 
                                                                                initStock(newValue);
                                                                                var sku=$('#skuCode').textbox('getValue');
                                                                                initSKU(sku);
                                                                              }" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">发货仓库：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="stoCode" name="stoCode" class="easyui-combobox"
                                                                data-options="required:true,editable:false" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">要求到货日期：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planReachDate" name="planReachDate"
                                                                class="easyui-datebox"
                                                                data-options="required:true,editable:false" />
                                                        </div>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">合同编号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input type="hidden" id="draId" />
                                                            <input id="conCode" name="conCode" class="easyui-textbox"
                                                                data-options="buttonText:'查询',prompt:'点击查询合同',onClickButton:function(){                                                       
                                                                if (!$('#facCode').combobox('getValue')) {
                                                                    $.messager.alert('消息', '请选择发货工厂!');
                                                                    return;
                                                                }
                                                                $('#selectContractWindow').window('open');
                                                            }" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">合同名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="conName" name="conName" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">签约工厂：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="conFactoryCode" class="easyui-combobox"
                                                                data-options="required:false,url:'sysDict/queryItemByTypeName?dicName=交货工厂',method:'get',
					                                                          valueField:'dicValue',textField:'dicName',panelHeight:'auto',editable:false,
                                                                              onChange: function(newValue,oldValue){ 
                                                                              
                                                                              }" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">订单类型：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="ordCode" name="ordCode" class="easyui-combobox"
                                                                data-options="required:true,editable:false,valueField: 'value',editable:false, 
                                                            onChange: function(newValue,oldValue){ 
                                                                if (newValue == '3'){
                                                                    $('.divplanReceiveCode').show();
                                                                    $('.divplanPreCode').show();
                                                                } else if(newValue == '5'){
                                                                    $('.divplanPreCode').hide();
                                                                    $('.divplanReceiveCode').hide();
                                                                }else{
                                                                    $('.divplanReceiveCode').hide();
                                                                    $('.divplanPreCode').show();
                                                                }                                                               
                                                              },
                                                        textField: 'label',panelHeight:'auto',data: [{
                                                            label: '标准销售订单',
                                                            value: '1'
                                                        },{
                                                            label: '跨公司销售订单',
                                                            value: '2'
                                                        },{
                                                            label: '调拨订单',
                                                            value: '3'
                                                        },{
                                                            label: '预装',
                                                            value: '5'
                                                        },{
                                                            label: '标准销售订单-加急',
                                                            value: '16'
                                                        },{
                                                            label: '跨公司销售订单-加急',
                                                            value: '17'
                                                        },{
                                                            label: '调拨订单-加急',
                                                            value: '18'
                                                        },{
                                                            label: '预装-加急',
                                                            value: '19'
                                                        }]" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">是否跨公司：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planStride" name="planStride"
                                                                class="easyui-combobox" data-options="required:true,editable:false,
                                                            textField: 'label',panelHeight:'auto',data: [{
                                                                label: '是',
                                                                value: '1'
                                                            },{
                                                                label: '否',
                                                                value: '0'
                                                            }]" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="divplanReceiveCode">收货仓库：</div>
                                                    </td>
                                                    <td>
                                                        <div class="divplanReceiveCode" id="divplanReceiveCode">
                                                            <input id="planReceiveCode" name="planReceiveCode"
                                                                class="easyui-combobox" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>外贸术语：</div>
                                                    </td>
                                                    <td>
                                                        <!-- <input id="foreignName" name="foreignName" class="easyui-textbox" /> -->
                                                        <input id="foreignName" name="foreignName" style="width: 170px"
                                                            class="easyui-combobox"
                                                            data-options="editable:false,required:false,url:'sysDict/queryItemByTypeName?dicName=国际外贸条款',method:'get',
                                                                 valueField:'dicValue',textField:'dicName',panelHeight:'auto'" />
                                                    </td>
                                                    <td>
                                                        <div class="divplanPreCode">预装编号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="divplanPreCode" id="divplanPreCode">
                                                            <input id="planPreCode" name="planPreCode"
                                                                class="easyui-combogrid" style="width:170px" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class=" ssec-label">客户编码：
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="cusCode" name="cusCode" class="easyui-textbox"
                                                                data-options="buttonText:'查询',required:true,prompt:'点击查询客户',onClickButton:function(){                                                       
                                                                if ($('#conCode').textbox('getValue')) {
                                                                    $.messager.alert('消息', '已经选择合同，不可改变!');
                                                                    return;
                                                                }
                                                                $('#selectCustomWindow').window('open');
                                                            }" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">客户名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="cusName" name="cusName" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">包装方式：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pakModeCode" name="pakModeCode"
                                                                class="easyui-combobox" data-options="required:true,url:'sysDict/queryItemByTypeName?dicName=包装方式',method:'get',
                                                            valueField:'dicValue',textField:'dicName',panelHeight:'auto',
                                                            onChange: function(newValue,oldValue){ 
                                                             
                                                            }" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">SKU：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="skuDetail" name="skuDetail"
                                                                class="easyui-combobox" data-options="required:true,editable:false,
                                                            valueField:'id',textField:'text',panelHeight:'auto',
                                                            onChange: function(newValue,oldValue){ 
                                                                if (!$('#facCode').combobox('getValue')) {
                                                                    $.messager.alert('消息', '请选择发货工厂!');
                                                                    return;
                                                                }else{
                                                                    initSKU(newValue);
                                                                }
                                                            }" style="width:140px;" />
                                                            <a href="javascript:void(0)" class="easyui-linkbutton"
                                                                data-options="onClick:function(){
                                                            if ($('#conCode').textbox('getValue')) {
                                                                $.messager.alert('消息', '已经选择合同，不可改变!');
                                                                return;
                                                            }
                                                            $('#selectSkuWindow').window('open');
                                                        }">查询</a>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">SKU编码：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="skuCode" name="skuCode" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">SKU数量：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="skuNum" name="skuNum" class="easyui-numberbox"
                                                                precision="3" data-options="required:true, onChange: function(newValue,oldValue){ 
                                                                initSKUWeight()
                                                            }" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">产品编码：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="proCode" name="proCode" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">产品名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="proName" name="proName" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">产品重量：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="proUnitNum" type="hidden" />
                                                            <input id="proNum" name="proNum" class="easyui-numberbox"
                                                                data-options="required:true" precision="3" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">包装物-1编码：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak1Code" name="pak1Code" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">包装物-1名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak1Name" name="pak1Name" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">包装物-1数量：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak1UnitNum" type="hidden" />
                                                            <input id="pak1Num" name="pak1Num" class="easyui-numberbox"
                                                                data-options="required:true" precision="0" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">包装物-2编码：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak2Code" name="pak2Code" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">包装物-2名称：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak2Name" name="pak2Name" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">包装物-2数量：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="pak2UnitNum" type="hidden" />
                                                            <input id="pak2Num" name="pak2Num" class="easyui-numberbox"
                                                                data-options="required:true" precision="0" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">提单号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planFetchNum" name="planFetchNum"
                                                                class="easyui-textbox" data-options="required:false" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class=" ssec-label">批号：
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planCheckNum" name="planCheckNum"
                                                                class="easyui-textbox" data-options="required:false" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class=" ssec-label">交货单号：
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="godNum" name="godNum" class="easyui-textbox"
                                                                data-options="required:true,disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">是否控重：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <!-- <input id="draIsPlanAccounting" name="draIsPlanAccounting"
                                                            class="easyui-textbox" data-options="required:true" /> -->
                                                            <input id="draIsPlanAccounting" name="draIsPlanAccounting"
                                                                style="width: 170px" class="easyui-combobox"
                                                                data-options="required:true,valueField:'value',
                                                        textField:'label',panelHeight:'auto', editable:false,panelHeight:'auto',
                                                        data: [{label: '是',value: '1',selected:true },{ label: '否', value: '0' }]" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class=" ssec-label">运输方式：
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="draTransportName" name="draTransportName"
                                                                style="width: 170px" class="easyui-combobox"
                                                                data-options="editable:false,required:true,
                                                        url:'sysDict/queryItemByTypeName?dicName=运输方式',method:'get',
                                                                      valueField:'dicValue',textField:'dicName',panelHeight:'auto'" />

                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">收货地址：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planReceiveRemark" name="planReceiveRemark"
                                                                class="easyui-textbox" data-options="required:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">收货电话：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planReceiveTel" name="planReceiveTel"
                                                                class="easyui-textbox" data-options="required:false" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class=" ssec-label">预计到厂时间：
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planArriveTime"
                                                                data-options="required:false,editable:false"
                                                                class="easyui-datetimebox">

                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">业务员：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input type="hidden" id="draCreatorId">
                                                            <input id="draCreator" name="draCreator"
                                                                class="easyui-textbox"
                                                                data-options="required:true,disabled:false" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">业务员部门：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="deptName" name="deptName" class="easyui-textbox"
                                                                data-options="required:false,disabled:false" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="6">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">订单备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planOrdRemark" name="planOrdRemark"
                                                                            style="width: 300px; height: 150px;"
                                                                            class="easyui-textbox"
                                                                            data-options="required:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-label">送货单备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planSendRemark" name="planSendRemark"
                                                                            style="width: 300px; height:150px"
                                                                            class="easyui-textbox"
                                                                            data-options="multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                </tr>
                                            </table>
                                        </form>
                                    </div>
                                    <div title="审核信息" style="padding: 5px;">
                                        <form id="frmCheck">
                                            <table>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">客服确认状态：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planServiceStatus" name="planServiceStatus"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">客服确认人：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planServiceName" name="planServiceName"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">客服确认人账号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planServiceAccount" name="planServiceAccount"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr style="border-bottom:1px;">
                                                    <td>
                                                        <div class="ssec-label">客服确认时间：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planServiceTime" name="planServiceTime"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td colspan="4">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">客服备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planServiceRemark"
                                                                            name="planServiceRemark"
                                                                            style="width: 300px; "
                                                                            class="easyui-textbox"
                                                                            data-options="disabled:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="6">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">物流确认状态：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planTmStatus" name="planTmStatus"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">物流确认人：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planTmName" name="planTmName"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">物流确认人账号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planTmAccount" name="planTmAccount"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">物流确认时间：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planTmTime" name="planTmTime"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td colspan="4">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">物流备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planTmRemark" name="planTmRemark"
                                                                            class="easyui-textbox" style="width: 300px;"
                                                                            data-options="disabled:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="6">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">生产确认状态：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planProdStatus" name="planProdStatus"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">生产确认人：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planProdName" name="planProdName"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">生产确认人账号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planProdAccount" name="planProdAccount"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">生产确认时间：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planProdTime" name="planProdTime"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td colspan="4">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">生产备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planProdRemark" name="planProdRemark"
                                                                            style="width: 300px; "
                                                                            class="easyui-textbox"
                                                                            data-options="disabled:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="6">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">储运确认状态：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planStorStatus" name="planStorStatus"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">储运确认人：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planStorName" name="planStorName"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">储运确认人账号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planStorAccount" name="planStorAccount"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">储运确认时间：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planStorTime" name="planStorTime"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td colspan="4">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">储运备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planStorRemark" name="planStorRemark"
                                                                            style="width: 300px; "
                                                                            class="easyui-textbox"
                                                                            data-options="disabled:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="6">
                                                        <hr>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">异常变更状态：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planExcStatus" name="planExcStatus"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">异常变更人：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planExcName" name="planExcName"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-label">异常变更人账号：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planExcAccount" name="planExcAccount"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div class="ssec-label">异常确认时间：</div>
                                                    </td>
                                                    <td>
                                                        <div class="ssec-text normal">
                                                            <input id="planExcTime" name="planExcTime"
                                                                class="easyui-textbox" data-options="disabled:true" />
                                                        </div>
                                                    </td>
                                                    <td colspan="4">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <div class="ssec-label">异常备注：</div>
                                                                </td>
                                                                <td>
                                                                    <div class="ssec-text normal">
                                                                        <input id="planExcRemark" name="planExcRemark"
                                                                            style="width: 300px; "
                                                                            class="easyui-textbox"
                                                                            data-options="disabled:true,multiline:true" />
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </form>
                                    </div>
                                    <div title="附件" style="padding: 5px;">
                                        <table>
                                            <tr>
                                                <td colspan="3"><input type="button" id="uploadbtn" value="选择文件..." />
                                                    <input type="file" id="uploadpicker" accept=""
                                                        onchange="changeFile()" multiple style="display: none;" />
                                                    <span>（文件名称不能包含斜杠、空格、&等特殊字符）</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><label style="width: 40%; text-align: right;">附件下载：</label>
                                                    <ul id="checkfileList"></ul>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
        </body>

        </html>